var prefix = ctx + "monitor/operlog"

window.onload = function() {
    loading();
};

function loading() {
    var columns = [
        {
            field: 'operName',
            title: '操作人员',
            sortable: true
        },
        {
            field: 'deptName',
            title: '部门名称'
        },
        {
            field: 'operIp',
            title: '主机'
        },
        {
            field: 'operLocation',
            title: '操作地点'
        },
        {
            field: 'status',
            title: '操作状态',
            align: 'center',
            formatter: function (value, row, index) {
                if (value == 0||value==""||value==null) {
                    return '<span class="badge badge-primary">成功</span>';
                } else if (value == 1) {
                    return '<span class="badge badge-danger">异常</span>';
                }
            }
        },
        {
            field: 'operStartTime',
            title: '操作时间',
            sortable: true
        },
        {
            field: 'duration',
            title: '耗时',
            sortable: true
        } ];
    var url = prefix + "/list";
    $.initTableParams(columns, url, queryParams);
}

function queryParams(params) {
    return {
        // 传递参数查询参数
        pageSize:       params.limit,
        pageNum:        params.offset / params.limit + 1,
        searchValue:    params.search,
        orderByColumn:  params.sort,
        isAsc:          params.order,
    };
}

/*操作日志-详细*/
function detail(id) {
    var url = prefix + '/detail/' + id;
    layer_showAuto("操作日志详细", url);
}

/*菜单管理-删除*/
function remove(id) {
    layer.confirm("确定要删除日志吗？",{icon: 3, title:'提示'},function(index){
        $.ajax({
            type : 'get',
            url: prefix + "/remove/" + id,
            success : function(r) {
                if (r.stat == web_status.SUCCESS) {
                    layer.msg(r.message, { icon: 1, time: 1000 });
                    loading();
                } else {
                    layer.alert(r.message, { icon: 2, title: "系统提示" });
                }
            }
        });
    });
}
